<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/layui/2.5.7/css/layui.css">
    <style>
        body {
            background-color: #f2f2f2;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }
        .login-wrapper {
            width: 400px;
            padding: 20px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        .login-wrapper .layui-form-item {
            margin-bottom: 20px;
        }
        .login-wrapper .layui-btn {
            width: 30%;
        }
        .error-message {
            color: red;
            margin-top: 10px;
        }
        .background-container {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            background-image: url("https://img95.699pic.com/photo/50258/2582.jpg_wh300.jpg");
            background-repeat: no-repeat;
            background-size: cover;
            filter: blur(5px); /* 虚化效果，可以根据需要调整模糊程度 */
        }

    </style>
</head>
<body>
<div class="background-container"></div>
<div class="login-wrapper">
    <h1 style="text-align: center; margin-bottom: 20px;">职工管理系统</h1>
    <form class="layui-form" lay-filter="login-form" th:action="@{/login}" method="post" id="loginform">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户类型</label>
            <div class="layui-input-block">
                <input type="radio" name="chose" value="1" title="管理员" checked>
                <input type="radio" name="chose" value="2" title="用户">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="login-submit">登录</button>
                <button class="layui-btn" type="button" }><a th:href="@{/register.html}">注册</a></button>

                </div>
        </div>
        <div class="error-message"  id="hide" th:if="${msg}">
            <p th:text="${msg}"></p>
        </div>
    </form>
</div>

<script src="https://cdn.staticfile.org/layui/2.5.7/layui.js"></script>
<script>
    function hide(){
        document.getElementById('hide').style.display="none";
    }
    setTimeout(hide,2000);
    layui.use(['form'], function() {
        var form = layui.form;

        // 监听表单提交
        form.on('submit(login-submit)', function(data){

            console.log(data.field);
            return true; // 允许表单提交
        });
    });
</script>
</body>
</html>
